package com.zx._06_JVM.chapter_02_gc;

/**
 * @version v1.0
 * @Project: jvm_example
 * @Title: D5_runtimeConstantPool
 * @Description: 演示-常量池(数据保存在方法区中)
 * @author: zhangxue
 * @date: 2018年9月15日下午9:51:33
 * @company: 未知
 * @Copyright: Copyright (c) 2015
 */
public class D5_runtimeConstantPool {

    /**
     * 运行时常量池
     */
    public static void main(final String[] args) {
        final String s1 = "abc";//"abc" 保持在运行时常量池中
        final String s2 = "abc";//"abc" 保持在运行时常量池中
        final String s3 = new String("abc");
        System.out.println(s1 == s2);//true
        System.out.println(s1 == s3);//false
        System.out.println(s2 == s3);//false
        System.out.println(s2 == s3.intern());//true   public native String intern()直接获得字符串对象的值在常量池中的值


    }
}
